package main

import "fmt"

//切片示例
func testSlice() {
	var slice []int
	var arr [5]int = [...]int{1, 2, 3, 4, 5}
	slice = arr[2:5]
	fmt.Println(slice)
	fmt.Println(len(slice))
	fmt.Println(cap(slice))

	slice = append(slice, 10)
	fmt.Println("扩容", len(slice), cap(slice))
	slice = append(slice, 13)
	fmt.Println("扩容", len(slice), cap(slice))
	slice = append(slice, 12)
	fmt.Println("扩容", len(slice), cap(slice))
	slice = append(slice, 11)
	fmt.Println("扩容", len(slice), cap(slice))
	fmt.Println(slice)
	slice[0] = 100
	fmt.Println(slice)
	fmt.Println(arr)
	fmt.Println("扩容", len(slice), cap(slice))

}

func main() {
	testSlice()
	testCopy()
}

func testCopy() {
	var a []int = []int{1, 2, 3, 4, 56}
	b := make([]int, 5)
	copy(b, a)
	fmt.Println(b)
}
